package com.cctc.security.aspectj;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.beans.factory.annotation.Autowired;

//@Component
//@Aspect
public class LogAspectj
{
    private  static  final Log logger=LogFactory.getLog(LogAspectj.class);
    @Autowired
    private HttpServletRequest request;
    
//    public Aop()
//    {
//        System.out.println("Aop");
//    }
    
    // @Around("within(org.springframework.web.bind.annotation.support.HandlerMethodInvoker..*)")
    // @Around("execution(* org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(..))")
    //@Around("execution(* *..controller.*.*(..))")
    public Object aa(ProceedingJoinPoint pjp) throws Throwable
    {
        System.out.println(request.getRemoteAddr());
        try
        {
            Object retVal = pjp.proceed();
            System.out.println(retVal);
            return retVal;
        }
        catch (Exception e)
        {
            System.out.println("异常");
            return null;
        }
    }
    
    //@Before("execution(* *..controller.*.*(..))")
    public void getlog()
    {
        logger.debug(request.getLocalName());
    }
}
